<?php
require_once 'config.php';
require_once 'common.php';
require_once 'ResultData.php';

$result = new ResultData();

$name = trim($_REQUEST['name']);
$psd = trim($_REQUEST['password']);


if ($name == "") {
    $result->code = 404;
    $result->msg = "name未填写";
    exit(json_encode($result));
}

if ($psd == "") {
    $result->code = 404;
    $result->msg = "password未填写";
    exit(json_encode($result));
}

$con = mysqli_connect($servername, $username, $password, $database, $port);

if (!$con) {
    $result->code = 404;
    $result->msg = "数据库连接不上";
    exit(json_encode($result));
}

$sql = "INSERT INTO t_login(name, password) VALUES('{$name}','{$psd}');";

$con->query($sql);

mysqli_close($con);

exit(json_encode($result));
